package com.javasm.crm.controller.gift;


import com.javasm.crm.common.http.AxiosResult;
import com.javasm.crm.controller.base.BaseController;
import com.javasm.crm.domin.criteria.GiftInfoCriteria;
import com.javasm.crm.domin.entity.gift.*;
import com.javasm.crm.service.giftservice.GiftGoodService;
import com.javasm.crm.service.giftservice.GiftInfoService;
import com.javasm.crm.service.giftservice.GoodsGiftService;
import com.javasm.crm.utils.page.PageResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author whl
 * @since 2021-07-12
 */
@RestController
@RequestMapping("GoodsGift")
@Api(value = "GoodsGiftController", description = "商品转赠品管理")

public class GoodsGiftController {

	@Autowired
	GoodsGiftService goodsGiftService;


	@GetMapping("getGoodsGift")
	@ApiOperation(value = "条件查询", notes = "条件查询")
	public AxiosResult<PageResult<GoodsGiftVo>> getGoodsGift(GiftInfoCriteria giftInfoCriteria) {
		PageResult<GoodsGiftVo> giftVoPageResult = goodsGiftService.searchPageByCriteria(giftInfoCriteria);
		return AxiosResult.success(giftVoPageResult);
	}


	@GetMapping("getGoodsGiftColor")
	@ApiOperation(value = "查询颜色", notes = "查询颜色")
	public AxiosResult<List<GiftColor>> getColor() {
		List<GiftColor> color = goodsGiftService.findColor();
		return AxiosResult.success(color);
	}

	@GetMapping("getGoodsGiftType")
	@ApiOperation(value = "查询类型", notes = "查询类型")
	public AxiosResult<List<GiftType>> getType() {
		List<GiftType> type = goodsGiftService.findType();
		return AxiosResult.success(type);
	}

	@GetMapping("getGoodsGiftBrand")
	@ApiOperation(value = "查询颜色", notes = "查询颜色")
	public AxiosResult<List<GiftBrand>> getBrand() {
		List<GiftBrand> brand = goodsGiftService.findBrand();
		return AxiosResult.success(brand);
	}

	@GetMapping("getGoodsGiftCheck")
	@ApiOperation(value = "查询审核", notes = "查询审核")
	public AxiosResult<List<GiftCheck>> getCheck() {
		List<GiftCheck> check = goodsGiftService.findCheck();
		return AxiosResult.success(check);
	}

	@PostMapping("addGoodsGift")
	@ApiOperation(value = "添加商品转赠品", notes = "添加商品转赠品")
	public AxiosResult<Integer> addGoodsGift(@RequestBody(required = false) GoodsGift goodsGift) {
		int save = goodsGiftService.addGoodsGift(goodsGift);
		return BaseController.toAxiosResult(save);
	}

	@PutMapping("editGoodsGift")
	@ApiOperation(value = "修改商品转赠品", notes = "修改商品转赠品")
	public AxiosResult<Integer> editGoodsGift(@RequestBody(required = false) GoodsGift goodsGift) {
		int save = goodsGiftService.editGoodsGift(goodsGift);
		return BaseController.toAxiosResult(save);
	}

	@DeleteMapping("deleteGoodsGiftById/{goodGiftid}")
	@ApiOperation(value = "删除赠品转商品", notes = "删除赠品转商品")
	public AxiosResult<Integer> deleteGoodsGift(@PathVariable Integer goodGiftid) {
		int deleteById = goodsGiftService.deleteById(goodGiftid);
		return BaseController.toAxiosResult(deleteById);
	}



}
